"use strict";
const e = require("../../common/vendor.js"),
  a = require("../../api/request.js"),
  o = require("../../api/cos.js"),
  u = require("../../api/qq-Location.js");
require("../../api/my-account.js"), require("../../api/qqmap-wx-jssdk.js");
const l = {
  __name: "Init-partner",
  setup(l) {
    e.hooks.locale("zh-cn");
    const t = e.ref(""),
      i = e.ref([]);
    async function n() {
      e.wx$1.chooseMedia({
        count: 3,
        mediaType: ["image"],
        sizeType: ["compressed"],
        sourceType: ["album", "camera"],
        success: async e => {
          e.tempFiles.forEach((e => {
            i.value.push(e)
          }))
        }
      })
    }
    const s = e.ref(""),
      c = e.ref("");

    function r() {
      e.wx$1.chooseLocation({
        success: async e => {
          const a = await u.addressCity(e.latitude, e.longitude);
          s.value = a.city, c.value = e.name
        },
        fail: e => {
          console.log(e)
        }
      })
    }
    const v = e.ref(""),
      p = e.hooks().format("YYYY-MM-DD"),
      f = e.hooks().add(1, "month").endOf("month").format("YYYY-MM-DD"),
      m = e.ref(p),
      d = e.ref(f);

    function h(e) {
      v.value = e.detail.value
    }
    const g = e.ref(null);

    function q(e) {
      g.value = Number(e.detail.value) + 1
    }
    const w = e.ref(!0);
    async function y() {
      e.wx$1.showLoading({
        title: "提交中",
        mask: !0
      }), await a.requestApi("/check_login");
      const u = await o.upLoadCos(i.value);
      await a.requestApi("/initiating_partner", {
        description: t.value,
        image: u,
        city: s.value,
        full_address: c.value,
        companion_time: v.value,
        number_of_people: g.value
      }, "POST"), e.wx$1.navigateTo({
        url: "/pages/companion/my-activities"
      })
    }
    return e.watchEffect((() => {
      const e = t.value && i.value.length > 0 && s.value && c.value && v.value && g.value > 0;
      w.value = !e
    })), (a, o) => e.e({
      a: t.value,
      b: e.o((e => t.value = e.detail.value)),
      c: e.f(i.value, ((a, o, u) => ({
        a: a.tempFilePath,
        b: e.o((e => function (e) {
          i.value.splice(e, 1)
        }(o)), o),
        c: o
      }))),
      d: i.value.length < 4
    }, i.value.length < 4 ? {
      e: e.o(n)
    } : {}, {
      f: e.o(r),
      g: c.value,
      h: e.o((e => c.value = e.detail.value)),
      i: v.value,
      j: e.o((e => v.value = e.detail.value)),
      k: e.o(h),
      l: m.value,
      m: d.value,
      n: g.value,
      o: e.o((e => g.value = e.detail.value)),
      p: e.o(q),
      q: [1, 2, 3, 4, 5, 6, 7, 8, 9],
      r: e.o(y),
      s: w.value
    })
  }
};
wx.createPage(l);